import request from "@/request/index.js";

// 获取参数分类列表
export function getCategories() {
    return request({
        url: '/mobile/categories',
        method: 'get'
    })
}

// 获取真实的参数分类（从后端分类API）
export function getRealCategories() {
    return request({
        url: '/param/category/list',
        method: 'get'
    })
}

// 获取分类树结构
export function getCategoryTree() {
    return request({
        url: '/param/category/tree',
        method: 'get'
    })
}

// 获取参数定义列表
export function getDefinitions(params) {
    return request({
        url: '/mobile/definitions',
        method: 'get',
        params: params
    })
}

// 获取参数详情
export function getDefinitionDetail(id) {
    return request({
        url: `/mobile/definitions/${id}`,
        method: 'get'
    })
}

// 创建参数定义
export function createDefinition(data) {
    return request({
        url: '/param/definitions',
        method: 'post',
        data
    })
}

// 检查参数键是否存在
export function checkParamKey(params) {
    return request({
        url: '/param/definitions/check-key',
        method: 'get',
        params
    })
}

// 规则引擎
export function getRules(params) {
    return request({
        url: '/param/rule/page',
        method: 'get',
        params
    })
}

// AI 推荐
export function getRecommendations(params) {
    return request({
        url: '/param/recommendation/page',
        method: 'get',
        params
    })
}

// 参数监控
export function getMetrics(params) {
    return request({
        url: '/param/metrics/page',
        method: 'get',
        params
    })
}

// 搜索参数
export function searchParameters(params) {
    return request({
        url: '/mobile/search',
        method: 'get',
        params: params
    })
}

// 获取通知列表
export function getNotifications() {
    return request({
        url: '/mobile/notifications',
        method: 'get'
    })
}

// 标记通知为已读
export function markNotificationAsRead(id) {
    return request({
        url: `/mobile/notifications/${id}/read`,
        method: 'post'
    })
}

// 参数值管理
export function getParamValues(params) {
    return request({
        url: '/param/value/page',
        method: 'get',
        params
    })
}

export function createParamValue(data) {
    return request({
        url: '/param/value',
        method: 'post',
        data
    })
}

export function updateParamValue(id, data) {
    return request({
        url: `/param/value/${id}`,
        method: 'put',
        data
    })
}

export function toggleParamValue(id, isActive) {
    return request({
        url: `/param/value/${id}/status/${isActive}`,
        method: 'put'
    })
}

export function getParamValueHistory(paramId) {
    return request({
        url: `/param/value/history/${paramId}`,
        method: 'get'
    })
}


